Reject customized built-in elements in attachShadow Element::CanAttachShadowRoot() needs to be updated because it returns wrongly true for customized built-in elements. The spec: https://dom.spec.whatwg.org/#dom-element-attachshadow Bug: 823033 Change-Id: Ia9aeb47569414830f5435f37f85d96101b9fe432 Reviewed-on: https://chromium-review.googlesource.com/970142 Reviewed-by: Koji Ishii <kojii@chromium.org> Reviewed-by: Kent Tamura <tkent@chromium.org> Commit-Queue: Hayato Ito <hayato@chromium.org> Cr-Commit-Position: refs/heads/master@{#545026} diff --git a/shadow-dom/Element-interface-attachShadow-custom-element.html b/shadow-dom/Element-interface-attachShadow-custom-element.html new file mode 100644 index 0000000..b59460e --- /dev/null +++ b/shadow-dom/Element-interface-attachShadow-custom-element.html
@@ -0,0 +1,29 @@ +<!DOCTYPE html> +<title>Shadow DOM: Attaching a ShadowRoot for custom elements</title> +<meta name="author" title="Hayato Ito" href="mailto:hayato@chromium.org"> +<link rel="help" href="https://dom.spec.whatwg.org/#dom-element-attachshadow"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +class MyAutonomousCustomElement extends HTMLElement { +} + +customElements.define('my-custom', MyAutonomousCustomElement); + +test(() => { + assert_true(document.createElement('my-custom').attachShadow({mode: "open"}) instanceof ShadowRoot); +}, 'Element.attachShadow must create an instance of ShadowRoot for autonomous custom elements'); + +class MyCustomizedBuiltinElement extends HTMLInputElement { +} + +customElements.define('my-input', MyCustomizedBuiltinElement, { extends: 'input' }); + +test(() => { + assert_throws({'name': 'NotSupportedError'}, () => { + document.createElement('input', {is: 'my-input'}).attachShadow({mode: "open"}); + }); +}, 'Element.attachShadow must throw a NotSupportedError for customized built-in elements'); +</script> +</body> +</html>